import { Select } from 'antd';
import { TextWidget } from '@inbiz/react';
import { Key } from 'rc-select/lib/interface/generator';

const { Option } = Select;
export default function MySelect(props: { defaultValue?: any; data?: any; onChange?: any; value?: any; }) {
  const { data = [], onChange, value = '1' } = props;
  const selectValue = data.length > 0 ? data : props.defaultValue;
  return (
    <Select onChange={onChange} defaultValue="1" value={value}>
      {selectValue
        ?.filter((ele: { hide: any; }) => !ele.hide)
        ?.map((item: { id: Key | undefined; title: any; }) => {
          return (
            <Option value={item.id} key={item.id}>
              <TextWidget>{item.title}</TextWidget>
            </Option>
          );
        })}
    </Select>
  );
}
